<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2011 Mia-Software. All rights reserved. This program and 
	the accompanying materials are made available under the terms of the Eclipse 
	Public License v1.0 which accompanies this distribution, and is available 
	at http://www.eclipse.org/legal/epl-v10.html Contributors: Gregoire DUPE 
	(Mia-Software) - initial contribution -->
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common"
	extension-element-prefixes="exsl" xmlns:m2="http://maven.apache.org/POM/4.0.0">
	<xsl:output indent="yes" />

	<xsl:param name="releng_dir" />

	<xsl:template match="/">
		<project
			xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
			xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<xsl:apply-templates select="//m2:project/*[name()!='build']" />
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-site-plugin</artifactId>
						<version>2.1</version>
						<executions>
							<execution>
								<phase>prepare-package</phase>
								<goals>
									<goal>site</goal>
								</goals>
								<configuration>
									<outputDirectory>${WORKSPACE}/target/test-reports-site
									</outputDirectory>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>1.7</version>
						<executions>
							<execution>
								<id>update-site-finalization</id>
								<phase>package</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<target>
										<xsl:comment>
											3 steps:
											1.) Registring tests reports
											2.) Pack200 generation
											3.) rebuild the update site
										</xsl:comment>
										<property name="maven_plugin_classpath" refid="maven.plugin.classpath" />

										<xsl:comment>
											First step
										</xsl:comment>
										<xsl:element name="ant">
											<xsl:attribute name="antfile">
												<xsl:value-of select="concat($releng_dir, '/ant-scripts.xml')" />
											</xsl:attribute>
											<xsl:attribute name="target">register-test-report</xsl:attribute>
											<property name="test.report.location" value="${WORKSPACE}/target/test-reports-site" />
										</xsl:element>
										<xsl:comment>
											Second step
										</xsl:comment>
										<xsl:element name="ant">
											<xsl:attribute name="antfile">
												<xsl:value-of select="concat($releng_dir, '/ant-scripts.xml')" />
											</xsl:attribute>
											<xsl:attribute name="target">generate-pack200-jars</xsl:attribute>
										</xsl:element>
										<xsl:comment>
											Third step
										</xsl:comment>
										<xsl:element name="ant">
											<xsl:attribute name="antfile">
												<xsl:value-of select="concat($releng_dir, '/ant-scripts.xml')" />
											</xsl:attribute>
											<xsl:attribute name="target">rebuild-update-site</xsl:attribute>
											<property name="build_qualifier">${buildQualifier}</property>
										</xsl:element>
									</target>
								</configuration>
							</execution>
						</executions>
						<dependencies>
							<dependency>
								<groupId>net.sf.saxon</groupId>
								<artifactId>saxon</artifactId>
								<version>8.7</version>
							</dependency>
							<dependency>
								<groupId>net.sf.saxon</groupId>
								<artifactId>saxon-dom</artifactId>
								<version>8.7</version>
							</dependency>
							<dependency>
								<groupId>ant-contrib</groupId>
								<artifactId>ant-contrib</artifactId>
								<version>1.0b3</version>
								<exclusions>
									<exclusion>
										<groupId>ant</groupId>
										<artifactId>ant</artifactId>
									</exclusion>
								</exclusions>
							</dependency>
						</dependencies>
					</plugin>
					<!-- In case there were others plugins configurations -->
					<xsl:apply-templates select="//m2:project/m2:build/m2:plugins/*" />
				</plugins>
				<!-- In case of other build configurations -->
				<xsl:apply-templates select="//m2:project/m2:build/*[name()!='plugins']" />
			</build>
			<reporting>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-surefire-report-plugin</artifactId>
						<version>2.12</version>
						<configuration>
							<outputName>EMF Facet Tests Report</outputName>
							<outputDirectory>${WORKSPACE}/target/test-reports-site
							</outputDirectory>
							<reportsDirectories>
								<reportsDirectory>${WORKSPACE}/target/test-reports
								</reportsDirectory>
							</reportsDirectories>
						</configuration>
						<!-- executions> <execution> <phase>prepare-package</phase> <goals> 
							<goal>report-only</goal> </goals> </execution> </executions -->
					</plugin>
				</plugins>
			</reporting>
		</project>
	</xsl:template>

	<xsl:template match="m2:*[name()!='build']|@*">
		<xsl:copy-of select="." />
	</xsl:template>

</xsl:stylesheet>
